package Code.Day1_20240918.com.dx.day01;

import java.util.ArrayList;

/**
 * @ClassName Test11
 * @Description 打断循环
 * @Author 12994
 * @Date 2024/9/18 22:11
 * @Version 1.0
 **/
public class Test11 {
    /**
     * break与continue
     */
    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            System.out.print(i);
            if (i == 5) {
                break;
            }
        }
        System.out.println("\n");

        int j = 0;
        while (j < 10) {
            System.out.print(j);
            if (j == 5) {
                break;
            }
            j++;
        }
        System.out.println("\n");

        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            if (i == 5) {
                continue;
            }
            list.add(i);
        }

        // 针对ArrayList的增强型遍历
        ArrayList<Integer> list2 = new ArrayList<>();
        for (Integer l : list) {
            if (l == 6) {
                continue;
            }
            list2.add(l);
        }

        System.out.println(list);
        System.out.println(list2);
    }
}
